/*
 * @Descripttion: 检查任务页面
 * @version: 
 * @Author: linPing
 * @Date: 2019-10-29 12:25:00
 * @LastEditTime: 2019-11-01 15:44:02
 */



import React, { Fragment } from 'react';

import { observer, inject } from 'mobx-react';
import Toast, { DURATION } from 'react-native-easy-toast';
import NavigationBar from '../common/NavigationBar';
import GlobalStyles from "../res/styles/GlobalStyles";
import { ButtonGroup } from 'react-native-elements'
import NavigationUtil from '../navigator/NavigationUtil'
import OffLineImagePick from "../common/OffLineImagePick";
import Icon from "../common/Images";
import AsyncStorageUtils from "../expand/AsyncStorage";
import ViewUtil from "../util/ViewUtil";
import ActionSheetContent from "./ActionSheetContent"
import SafeAreaViewPlus from "../common/SafeAreaViewPlus";
import VisibleView from "../common/VisibleView";
import TreeSelect from '../component/treeSelect/index';
import ActionSheet from 'react-native-actionsheet';

import {
    SafeAreaView,
    StyleSheet,
    ScrollView,
    TouchableOpacity,
    Button,
    View,
    Text,
    StatusBar,
    FlatList,
    Image,
    TextInput,
    NativeModules,
    Alert,
    Dimensions
} from 'react-native';

const treeselectData = [
    {
        "id": "A",
        "name": "农、林、牧、渔业",
        "sortNo": "A",
        "parentId": "0",
        "children": [
            {
                "id": "A01",
                "name": "农业",

                "parentId": "A",
                "children": [
                    {
                        "id": "A011",
                        "name": "6.5.2 应妥善防护具有爆炸危险性的仪器设备",
                        "sortNo": "A011",
                        "parentId": "A01",
                        "desc": "有处级实验室安全主管职能部门，其他相关职能部门分工合作；有处级实验室安全主管职能部门，其他相关职能部门分工合作；有处级实验室安全主管职能部门，其他相关职能部门分工合作；建议3万学生规模以上且仪器设备总值超过3亿元的学校设立实验室安全管理科室；规模较小的高校或文科类学校可以不设独立科室"
                    },
                    {
                        "id": "A012",
                        "name": "豆类、油料和薯类种植",
                        "sortNo": "A012",
                        "parentId": "A01",
                        "desc": "有处级实验室安全主管职能部门，其他相关职能部门分工合作；"
                    },
                    {
                        "id": "A013",
                        "name": "棉、麻、糖、烟草种植",
                        "sortNo": "A013",
                        "parentId": "A01"
                    },
                    {
                        "id": "A014",
                        "name": "蔬菜、食用菌及园艺作物种植",
                        "sortNo": "A014",
                        "parentId": "A01"
                    },
                    {
                        "id": "A015",
                        "name": "水果种植",
                        "sortNo": "A015",
                        "parentId": "A01"
                    },
                    {
                        "id": "A016",
                        "name": "坚果、含油果、香料和饮料作物种植",
                        "sortNo": "A016",
                        "parentId": "A01"
                    },
                    {
                        "id": "A017",
                        "name": "中药材种植",
                        "sortNo": "A017",
                        "parentId": "A01"
                    }
                ]
            }
        ]
    },
    {
        "id": "B",
        "name": "采矿业",
        "sortNo": "B",
        "parentId": "0",
        "children": [
            {
                "id": "B06",
                "name": "煤炭开采和洗选业",
                "sortNo": "B06",
                "parentId": "B",
                "children": [
                    {
                        "id": "B061",
                        "name": "烟煤和无烟煤和无烟煤开采洗选烟煤和无烟煤开采洗选烟煤和无烟煤开采洗选烟煤开采洗选",
                        "sortNo": "B061",
                        "parentId": "B06"
                    },
                    {
                        "id": "B062",
                        "name": "褐煤开采洗选",
                        "sortNo": "B062",
                        "parentId": "B06"
                    },
                    {
                        "id": "B069",
                        "name": "其他煤炭采选",
                        "sortNo": "B069",
                        "parentId": "B06"
                    }
                ]
            }
        ]
    }
]



const { width, height } = Dimensions.get('window')
// import { TouchableOpacity } from 'react-native-gesture-handler';

@inject('appStore')
@observer
export default class TaskRoomList extends React.Component {
    constructor(props) {
        super(props)

        this.params = this.props.navigation.state.params
        this.originalData = this.params.item
        this.title = "检查项"
        this.state = {
            inputText: "",
            defaultValue: "",
            imgShowList: [],
            showAction: false,
            selectData: { title: '', desc: '' }
            // dataList: this.originalData.room
        }

    }


    onBack = () => {
        NavigationUtil.goBack(this.props.navigation);
    }
    _onClickLeaf = (data) => {


        this.setState({
            selectData: data.item
        })
        this.ActionSheet.show()
        console.log(data)

    }
    render() {
        const { navigation } = this.props
        const { appStore, appStore: { theme } } = this.props


        let statusBar = {
            backgroundColor: theme,
            barStyle: 'light-content',
        };
        let navigationBar =
            <NavigationBar
                title={this.title}
                statusBar={statusBar}
                leftButton={ViewUtil.getLeftBackButton(() => this.onBack())}
                // rightButton={ViewUtil.getRightButton("保存", () => this.onSave())}
                style={{ backgroundColor: theme }}
            />;



        const styles = {
            // titleBox: {
            //     paddingHorizontal:10,
            // },
            titleText: {
                paddingHorizontal: 10,
                paddingVertical: 6,
                fontSize: 14,
                color: '#333'
            },
            messageBox: {
                padding: 10,
                marginTop: 0.5,
                height: 120,
                justifyContent: "flex-start",
            },
            messageText: {
                lineHeight: 20,
                color: "#666"
            }
        }

        return (

            <SafeAreaViewPlus style={GlobalStyles.root_container}>

                {navigationBar}

                <ActionSheet
                    ref={o => this.ActionSheet = o}
                    title={this.state.selectData.name}
                    message={this.state.selectData.desc}
                    options={["添加", <Text style={{ color: 'red' }}>取消</Text>]}
                    cancelButtonIndex={1}

                    styles={styles}
                    //   destructiveButtonIndex={1}
                    onPress={(index) => {
                        if (index === 0) {
                            this.props.navigation.state.params.getCheckItem(this.state.selectData)
                            this.onBack()
                        } else if (index === 1) {
                            // this.picksingle()
                        }
                    }}
                />

                {/* <ActionSheetContent
                    ref="ActionSheetContent"
                    content={this.state.selectData}
                    // items={[{title:'多次电话未接通',id:'1'},{title:'用户放弃',id:'2'},{title:'活动按钮',id:'3'}]}
                    actionsheetItemClick={this.actionsheetItemClick}
                    modalTitle={"确认选择"} /> */}

                <TreeSelect
                    data={treeselectData}
                    // isOpen
                    // openIds={['A01']}
                    // defaultSelectedId={['B062']}
                    isShowTreeId={false}
                    // selectType="single"
                    // selectType="multiple"
                    itemStyle={{
                        backgroudColor: '#f0f0f0',

                        paddingLeft: 100,
                        fontSize: 13,
                        color: '#555'
                    }}
                    selectedItemStyle={{
                        backgroudColor: '#f0f0f0',
                        fontSize: 13,
                        color: '#3385ff'
                    }}
                    onClick={this._onClick}
                    onClickLeaf={this._onClickLeaf}
                    treeNodeStyle={{
                        paddingHorizontal: 10,
                        // openIcon: <Icon size={18} color="#171e99" style={{ marginRight: 10 }} name="ios-arrow-down" />,
                        // closeIcon: <Icon size={18} color="#171e99" style={{ marginRight: 10 }} name="ios-arrow-forward" />
                        // openIcon: <Image
                        //     resizeMode="stretch"
                        //     style={{ width: 18, height: 18 }}
                        //     source={require('./images/down-circle.png')} />,
                        // closeIcon: <Image
                        //     resizeMode="stretch"
                        //     style={{ width: 18, height: 18 }}
                        //     source={require('./images/right-circle.png')} />
                    }}
                />
             </SafeAreaViewPlus>

        )
    }

};


const styles = StyleSheet.create({

    astyle: {
        display: "none",
        padding: 50,


    }
});

